/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package com.minierp.validator;

import com.minierp.model.WorkCenter;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

public class WorkCenterValidator implements Validator {
	public boolean supports(Class clazz) {
		return WorkCenter.class.isAssignableFrom(clazz);
	}

	public void validate(Object obj, Errors errors) {
		WorkCenter form = (WorkCenter) obj;
		if (form.getWcName() != null && !form.getWcName().trim().equals("")) {
			if (form.getStorehouseId() == 0L) {
				errors.rejectValue("storehouseId", "", "请选择『仓库』");
			}
		} else {
			errors.rejectValue("wcName", "", "请输入『名称』");
		}

	}
}